package com.sifang.sfuserservice.controller;

import com.sifang.sfuserservice.annotation.LogAnnotation;
import com.sifang.sfuserservice.dto.UserDto;
import com.sifang.sfuserservice.response.ServerResponseEntity;
import com.sifang.sfuserservice.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;



/**
 * 日志处理类
 */
@Slf4j
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;


    @LogAnnotation(module = "用户服务",operator = "用户注册")
    @PostMapping("/register")
    public ServerResponseEntity<String> register(@Validated @RequestBody UserDto userDto){
        try {
            userService.register(userDto);
            //Thread.sleep(2000);
        } catch (Exception e) {
            log.error(e.getMessage());
            throw new RuntimeException(e.getMessage());
        }
        return ServerResponseEntity.success();
    }
}
